﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Workflow.Dto;
using Workflow.IDAO;
using Workflow.IService;
using Workflow.Model;

namespace Workflow.Service
{
	public class ApplicatService : IApplicatService
	{
		public IApplicatDao ApplicatDao { get; set; }


		public IList<Applicat> GetApplicatList()
		{
			return ApplicatDao.LoadAll().ToList();
		}

		public Applicat GetApplicatById(string id)
		{
			return ApplicatDao.Get(id);
		}

		public Applicat GetApplicatByMail(string mail)
		{
			return ApplicatDao.GetApplicatByMail(mail);
		}

		public void SaveApplicatList(DataTable dt)
		{

			foreach (DataRow row in dt.Rows)
			{
				if(string.IsNullOrEmpty( row["MSD社員番号"].ToString()))
				{
					continue;
				}
				Applicat applicat = new Applicat();
				applicat.ID = row["MSD社員番号"].ToString();
				applicat.Name = row["氏名"].ToString();
				applicat.Email = row["メールアドレス"].ToString();
				applicat.ISID = row["ISID"].ToString();

				ApplicatDao.SaveOrUpdate(applicat);
			}
		}

		public Applicat GetApplicatByDto(ApplicatQueryDto applicatQueryDto)
		{
			return ApplicatDao.GetApplicatByDto(applicatQueryDto);
		}

	}
}
